import request from '@/utils/request'

// 帖子相关 API

// 创建圈子帖子
export function createCirclePost(data) {
    return request({
        url: '/circle-posts',
        method: 'post',
        data
    })
}

// 获取圈子帖子列表
export function getCirclePosts(circleId, params) {
    return request({
        url: `/circles/${circleId}/posts`,
        method: 'get',
        params
    })
}

// 获取帖子详情
export function getCirclePostDetail(postId) {
    return request({
        url: `/circle-posts/${postId}`,
        method: 'get'
    })
}

// 更新帖子信息
export function updateCirclePost(postId, data) {
    return request({
        url: `/circle-posts/${postId}`,
        method: 'put',
        data
    })
}

// 删除帖子
export function deleteCirclePost(postId) {
    return request({
        url: `/circle-posts/${postId}`,
        method: 'delete'
    })
}

// 点赞帖子
export function likeCirclePost(postId) {
    return request({
        url: `/circle-posts/${postId}/like`,
        method: 'post'
    })
}

// 取消点赞帖子
export function unlikeCirclePost(postId) {
    return request({
        url: `/circle-posts/${postId}/unlike`,
        method: 'post'
    })
}

// 获取用户在所有圈子中的帖子
export function getUserCirclePosts(params) {
    return request({
        url: '/circle-posts/user/posts',
        method: 'get',
        params
    })
}

// 获取热门圈子帖子
export function getHotCirclePosts(params) {
    return request({
        url: '/circle-posts/hot',
        method: 'get',
        params
    })
}

// 搜索圈子帖子
export function searchCirclePosts(params) {
    return request({
        url: '/circle-posts/search',
        method: 'get',
        params
    })
}

// 评论相关 API

// 创建评论
export function createComment(data) {
    return request({
        url: '/circle/post/comment',
        method: 'post',
        data
    })
}

// 获取评论列表
export function getComments(params) {
    return request({
        url: '/circle/post/comment',
        method: 'get',
        params
    })
}

// 获取评论详情
export function getCommentDetail(commentId) {
    return request({
        url: `/circle/post/comment/${commentId}`,
        method: 'get'
    })
}

// 更新评论
export function updateComment(commentId, data) {
    return request({
        url: `/circle/post/comment/${commentId}`,
        method: 'put',
        data
    })
}

// 删除评论
export function deleteComment(commentId) {
    return request({
        url: `/circle/post/comment/${commentId}`,
        method: 'delete'
    })
}

// 获取评论回复列表
export function getCommentReplies(params) {
    return request({
        url: '/circle/post/comment/replies',
        method: 'get',
        params
    })
}